﻿<div id="data-grid-demo">
    @(Html.DevExtreme().DataGrid<DevExtreme.NETCore.Demos.Models.DataGrid.Employee>()
        .ID("gridContainer")
        .ShowBorders(true)
        .Paging(paging => paging.Enabled(false))
        .Editing(editing => {
            editing.Mode(GridEditMode.Form);
            editing.AllowUpdating(true);
        })
        .Columns(columns => {
            columns.AddFor(m => m.Prefix)
                .Width(70);

            columns.AddFor(m => m.FirstName);

            columns.AddFor(m => m.LastName);

            columns.AddFor(m => m.Position)
                .Width(170);

            columns.AddFor(m => m.StateID)
                .Width(125)
                .Lookup(lookup => lookup
                    .DataSource(d => d.Mvc().Controller("DataGridStatesLookup").LoadAction("Get").Key("ID"))
                    .DisplayExpr("Name")
                    .ValueExpr("ID")
                );

            columns.AddFor(m => m.BirthDate);

            columns.AddFor(m => m.Notes)
                .Visible(false)
                .FormItem(i => i
                    .Editor(e => e
                        .TextArea()
                        .Height(100))
                    .ColSpan(2)
                );
        })
        .DataSource(d => d.Mvc()
            .Controller("DataGridEmployees")
            .LoadAction("Get")
            .UpdateAction("Put")
            .Key("ID")
        )
        .DataSourceOptions(d => d.Filter("['ID', '<=' , 10]"))
    )
</div>
